package org.bonorsoft.modules.wechat.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.bonorsoft.modules.wechat.mapper.PicturePhotoMapper;
import org.bonorsoft.modules.wechat.service.IPicturePhotoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
public class PicturePhotoServiceImpl implements IPicturePhotoService {

    @Resource
    private PicturePhotoMapper picturePhotoMapper;

    /**
     * 添加图片
     *
     * @param id
     * @param photo
     */
    @Override
    public int addPhoto(String id, String photo) {
        return picturePhotoMapper.addPhoto(id,photo);
    }

    /**
     * 获取图片
     *
     * @param id
     * @return
     */
    @Override
    public String getPhoto(String id) {
        return picturePhotoMapper.getPhoto(id);
    }

    /**
     * 删除图片
     *
     * @param id
     */
    @Override
    public void deletePhoto(String id) {
        picturePhotoMapper.deletePhoto(id);
    }

    /**
     * 批量删除
     *
     * @param ids
     */
    @Override
    public void deletePhotoByIds(List<String> ids) {
        for (String id : ids) {
            picturePhotoMapper.deletePhoto(id);
        }
    }

    /**
     * 判断有无照片
     *
     * @param id
     * @return
     */
    @Override
    public int count(String id) {
        return picturePhotoMapper.count(id);
    }

    /**
     * 更新图片
     *
     * @param id
     * @param photo
     * @return
     */
    @Override
    public int update(String id, String photo) {
        return picturePhotoMapper.update(id,photo);
    }
}
